<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	
	<script type="text/javascript">

	function AAA1(a,b){  
	    return(a+b);  
	}  
	function AAA2(a,b){  
	    return(a-b);  
	}  
	var aaa = AAA1.call(AAA2,3,1);//AAA1替代AAA2
	console.log(aaa)



	function BBB1(){    
	    this.name = "BBB1";    
	    this.showName = function(){    
	        return this.name; 
	    }    
	}      
	function BBB2(){    
	    this.name = "BBB2";    
	}       
	var bbb1 = new BBB1();    
	var bbb2 = new BBB2();       
	//通过call或apply方法，将原本属于BBB1对象的showName()方法交给对象bbb来使用了。    
	//输入结果为"BBB2"    
	var bbb = bbb1.showName.call(bbb2,",");
	console.log(bbb)
	//animal.showName.apply(bbb,[]);



	function CCC1(name){      
    	this.name = name;      
	    this.showName = function(){      
	        return this.name;
	    }      
	}          
	function CCC2(name){    
	    CCC1.call(this, name);
	}        
	var ccc = new CCC2("Black CCC2");     
	console.log(ccc.showName())




	function DDD1(){  
	    this.showSub = function(a,b){  
	        return(a-b);  
	    }  
	}    
	function DDD2(){  
	    this.showAdd = function(a,b){  
	        return(a+b);  
	    }  
	}   
	function DDD(){ 
	    DDD1.call(this);
	    DDD2.call(this);  
	}  
	var ddd = new DDD();
	console.log(ddd.showSub(20,10))
	console.log(ddd.showAdd(20,10))


	</script>
</body>
</html>